home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Action / Action.cp next >
Text File  |  2000-06-23  |  764b  |  47 lines

  1. // Action.cp
  2.  
  3. #ifndef Action_h
  4. #include "Action.h"
  5. #endif
  6. #ifndef Assert_h
  7. #include "Assert.h"
  8. #endif
  9.  
  10. bool Action::CanUndo() const
  11.   {
  12.     return true;
  13.   }
  14.  
  15. bool Action::CanRedo() const
  16.   {
  17.     return true;
  18.   }
  19.  
  20. void Action::Commit( bool )
  21.   {
  22.   }
  23.  
  24. Action& Action::Nothing()
  25.   {
  26.     class NoAction: public Action
  27.       {
  28.         virtual void Undo()                {}
  29.         virtual void Redo()                {}
  30.       };
  31.     static NoAction nothing;
  32.     return nothing;
  33.   }
  34.  
  35. Action& Action::Irreversible()
  36.   {
  37.     class IrreversibleAction: public Action
  38.       {
  39.         virtual bool CanUndo() const    { return false; }
  40.         virtual bool CanRedo() const    { return false; }
  41.         virtual void Undo()                { Assert( false ); }
  42.         virtual void Redo()                { Assert( false ); }
  43.       };
  44.     static IrreversibleAction irreversible;
  45.     return irreversible;
  46.   }
  47.